# -*- coding: utf-8 -*-
# @Time    : 2021/4/14 0014 9:46
# @Author  : 蒋才果
# @Email   : 1476235300@qq.com
# @File    : 4.14.py
# @Software: PyCharm
# ip存储余读取文件统计IP频率
# import random
# for i in range(50):
#     with open('big.txt','a',encoding='utf-8') as f:
#         r = random.randint(0,256)
#         f.write(f'127.25.254.{r}\n')
# word_dic = {}
# with open('big.txt','r',encoding='utf-8') as f:
#     for word_ip in f:
#         word_ip = word_ip.strip()
#         if word_ip in word_dic:
#             word_dic[word_ip] += 1
#         else:
#             word_dic[word_ip] = 1
#     for i in range(10):
#         print(max(word_dic,key=word_dic.get))
#         word_dic.pop(max(word_dic,key=word_dic.get))

# ####访客
# def w_name():
#     name = input('请输入你的名字：')
#     if name == 'q':
#         exit()
#     else:
#         with open('guest.txt','a',encoding='utf-8') as f:
#             f.write(f'{name}\n')
#             w_name()
# w_name()


# ####生成100个MAC地址并写入文件中，MAC地址前6位为01-AF-3B
# import random
# for i in range(10):
#     a = "".join(random.sample('0123456789ABCDEF',2))
#     b = "".join(random.sample('0123456789ABCDEF',2))
#     c = "".join(random.sample('0123456789ABCDEF',2))
#     with open("MAC.txt",'a',encoding='utf-8') as f:
#         f.write(f'01-AF-3B-{a}-{b}-{c}\n')

# ###词频统计
# dic = {}
# with open('Walden.txt', 'r', encoding='utf-8') as f:
#     # f2 = f.read().split()
#     # print(f.read().lower())
#     f2 = f.read().lower().split()
#     for words in f2:
#         if words.isalpha():
#             if words in dic:
#                 dic[words] += 1
#             else:
#                 dic[words] = 1
#     print(dic)